<template>
  <div class="container" v-loading="isLoading">
    <el-card>
      <template #header>
        <el-form inline :model="searchForm" ref="searchForm">
          <el-form-item label="标题">
            <el-input
              v-model="searchForm.user"
              placeholder="请输入活动标题"
            ></el-input>
          </el-form-item>
          <el-form-item label="活动时间">
            <el-date-picker
              v-model="searchForm.$time"
              type="date"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitSearch">查询</el-button>
          </el-form-item>
        </el-form>
        <div class="table_tool">
          <el-button
            type="primary"
            icon="el-icon-plus"
            @click="showAddOrEdit = true"
            >新增</el-button
          >
        </div>
      </template>
      <el-table :data="tableData" border>
        <el-table-column prop="author" label="标题" />
        <el-table-column prop="author" label="资讯类型" />
        <el-table-column prop="author" label="报名人数" />
        <el-table-column prop="author" label="评论人数" />
        <el-table-column label="操作" width="120px" align="center">
          <template slot-scope="{ row }">
            <el-button type="text" @click="openEditRow(row, 'builingForm')"
              >编辑</el-button
            >
            <el-button type="text" @click="delRowById(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <footer class="footer">
      <el-pagination
        background
        layout="total, sizes, pager, jumper"
        :current-page="pagination.page"
        :page-sizes="[10, 20, 30, 50, 100]"
        :page-size="pagination.page_size"
        :total="tableTotal"
        @size-change="(val) => (pagination.page_size = val)"
        @current-change="(val) => (pagination.page = val)"
      />
    </footer>

    <el-dialog
      :title="(builingForm.$id ? '编辑' : '新增') + '活动'"
      :visible.sync="showAddOrEdit"
      width="1000px"
      @closed="() => $refs['builingForm'].resetFields()"
    >
      <el-form
        :model="builingForm"
        :rules="builingRules"
        ref="builingForm"
        label-width="5em"
      >
        <el-form-item prop="$id" hidden />
        <el-form-item label="活动标题" prop="name">
          <el-input
            v-model="builingForm.name"
            placeholder="请输入活动标题"
          ></el-input>
        </el-form-item>
        <el-row>
          <el-col :span="8">
            <el-form-item label="活动话题">
              <el-select v-model="builingForm.region" placeholder="请选择话题">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="资讯类型">
              <el-select
                v-model="builingForm.region"
                placeholder="请选择资讯类型"
              >
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="人数限制" prop="input1">
              <el-input
                placeholder="请输入人数限制"
                v-model.number="builingForm.input1"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item prop="$image_uri" hidden/>
        <el-form-item label="图片" prop="file">
          <Upload
            v-model="builingForm.$image_uri"
            :file.sync="builingForm.file"
          />
        </el-form-item>
        <tinymce v-model="builingForm.content" :height="300" />
      </el-form>
      <template #footer>
        <el-button
          type="primary"
          @click="submitRowData('builingForm')"
          :loading="loading.update"
          >确 定</el-button
        >
      </template>
    </el-dialog>
  </div>
</template>

<script>
import { table, addOrEdit } from "@/utils/mixins";
import Tinymce from "@/components/Tinymce";
import Upload from "@/components/Upload/SingleImage.vue";
export default {
  mixins: [table, addOrEdit],
  components: {
    Tinymce,
    Upload,
  },
  data: () => ({
    searchForm: {
      $action: ["getList"],
    },
    builingForm: {
      $isFormData: true, // 是否提交 formData
      $action: [],
      name: "",
    },
    builingRules: {
      input1: {
        type: "number",
        message: "请输入数字",
      },
    },
    // showAddOrEdit: true,
  }),
  methods: {
     
  },
};
</script>

<style lang="scss" scoped></style>
